package com.mall.czlr.app.model;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.DigestUtils;

import java.util.UUID;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("token")
public class Token {
    @TableId private Long id;
    @TableField("token") private String token;
    @TableField("status") private Integer status;
    @TableField("user_id") private Long userId;
    @TableField("user_type") private Integer userType;
    @TableField("create_time") private Long createTime;
    @TableField("update_time") private Long updateTime;

    public static String makeToken () {
        String token = System.currentTimeMillis() + ":" + Math.random() + ":" + UUID.randomUUID().toString();
        return DigestUtils.md5DigestAsHex(token.getBytes());
    }
}
